package demo05

/**
 * @author xiaoZhao
 * @date 2022/6/30
 * @describe  匿名子类 只针对抽象类和接口
 */
object Test10_AnnoymousClass {
  def main(args: Array[String]): Unit = {
    // 匿名子类实现
    val person10 = new Person10 {
      override var name: String = "alice"

      override def eat(): Unit = println("person eat")
    }

    println(person10.name)
    person10.eat()
  }
}

abstract class Person10 {
  var name: String
  def eat():Unit
}